package com.smart.upms.sys.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smart.core.starter.base.BaseController;
import com.smart.core.starter.model.R;
import com.smart.upms.sys.param.SysLogParam;
import com.smart.upms.sys.param.SysLogQueryParam;
import com.smart.upms.sys.result.SysLogResult;
import com.smart.upms.sys.service.ISysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 日志表 前端控制器
 * </p>
 *
 * @author guxiaobai
 * @since 2018-12-05
 */
@Api(description = "日志接口")
@RestController
@RequestMapping("/sys/sys-log")
@AllArgsConstructor
public class SysLogController extends BaseController {

    private final ISysLogService sysLogService;


    /**
     * 添加日志
     *
     * @param param 日志实体
     * @return success/false
     */
    @ApiOperation(value = "添加日志")
    @PostMapping
    public R<Boolean> add(@Validated @RequestBody SysLogParam param) {
        return R.success(sysLogService.save(param));
    }


    /**
     * 分页查询
     *
     * @param param 查询参数
     * @return
     */
    @ApiOperation(value = "分页查询")
    @GetMapping("/page")
    public R<Page<SysLogResult>> page(SysLogQueryParam param) {
        Page<SysLogResult> page = getPage(param);
        return R.success(sysLogService.listPage(page, param));
    }


}
